/**
 * 试管架
 */
Rack = Widget.extend({
	ctor:function(parent){
		this._super();
		parent.addChild(this,30);
		this.setTag(TAG_RACK);
		this.init();
	},
	init : function(){
		this.setVisible(false);
		this.setCascadeOpacityEnabled(true);
		
		var rack=new Button(this,10,TAG_RACK1,"#rack1.png",this.callback);
		rack.setPosition(cc.p(350, 300));
		
		var rack1=new Button(this,11,TAG_RACK2,"#rack2.png",this.callback);
		rack1.setPosition(cc.p(350,300));
		
		var tube=new Button(this,10,TAG_TUBE,"#tube1.png",this.callback);
		tube.setPosition(cc.p(245,335));
		
		var line=new Button(tube,10,TAG_LINE_1,"#line1.png",this.callback);
		line.setPosition(cc.p(tube.width*0.5, tube.height*0.3));
		
		var tube1=new Button(this,10,TAG_TUBE1,"#tube1.png",this.callback);
		tube1.setPosition(cc.p(288,335));
		
		var tube1_1=new Button(this,10,TAG_TUBE6,"#tube4.png",this.callback);
		tube1_1.setPosition(cc.p(288,335));
		tube1_1.setOpacity(0);
		
		var line1=new Button(tube1,10,TAG_LINE_2,"#line1.png",this.callback);
		line1.setPosition(cc.p(tube1.width*0.5, 0));
		line1.setScale(0.1);
		line1.setVisible(false);
		
		var tube2=new Button(this,10,TAG_TUBE2,"#tube1.png",this.callback);
		tube2.setPosition(cc.p(331,335));
		
		var line2=new Button(tube2,10,TAG_LINE_3,"#line1.png",this.callback);
		line2.setPosition(cc.p(tube2.width*0.5, 0));
		line2.setScale(0.1);
		line2.setVisible(false);

		var tube3=new Button(this,10,TAG_TUBE3,"#tube1.png",this.callback);
		tube3.setPosition(cc.p(374,335));
		
		var tube4=new Button(this,10,TAG_TUBE4,"#tube1.png",this.callback);
		tube4.setPosition(cc.p(417,335));
		
		var tube5=new Button(this,10,TAG_TUBE5,"#tube1.png",this.callback);
		tube5.setPosition(cc.p(460,335));
	},
	tubeFadein:function(){
		var fadein=cc.fadeIn(1);
		var tube1_1=this.getChildByTag(TAG_TUBE6);
		tube1_1.runAction(fadein);
	},
	upLine:function(){
		var tube=this.getChildByTag(TAG_TUBE);
		var line=tube.getChildByTag(TAG_LINE_1);
		var move=cc.moveBy(1,cc.p(0, 8));
		line.runAction(move);
	},
	takeTube1:function(){
		var tube1=this.getChildByTag(TAG_TUBE1);
		var ber=cc.bezierBy(1, [cc.p(5, 85),cc.p(10,150),cc.p(10, 188)]);
		var rotate=cc.rotateBy(1,10);
		tube1.runAction(cc.spawn(ber,rotate));
	},
	putTube1:function(){
		var tube1=this.getChildByTag(TAG_TUBE1);
		var ber=cc.bezierBy(1, [cc.p(5, 85),cc.p(10,150),cc.p(10, 188)]);
		var rotate=cc.rotateBy(1,10);
		tube1.runAction(cc.spawn(ber.reverse(),rotate.reverse()));
	},
	takeTube2:function(){
		var tube1=this.getChildByTag(TAG_TUBE2);
		var ber=cc.bezierBy(1, [cc.p(5, 85),cc.p(10,150),cc.p(10, 188)]);
		var rotate=cc.rotateBy(1,10);
		tube1.runAction(cc.spawn(ber,rotate));
	},
	putTube2:function(){
		var tube1=this.getChildByTag(TAG_TUBE2);
		var ber=cc.bezierBy(1, [cc.p(5, 85),cc.p(10,150),cc.p(10, 188)]);
		var rotate=cc.rotateBy(1,10);
		tube1.runAction(cc.spawn(ber.reverse(),rotate.reverse()));
	},
	upLine1:function(){
		var tube1=this.getChildByTag(TAG_TUBE1);
		var line1=tube1.getChildByTag(TAG_LINE_2);
		line1.setVisible(true);
		var move1=cc.moveBy(0.2,cc.p(0, 10));
		var scale=cc.scaleBy(0.2,10);
		var move2=cc.moveBy(0.8,cc.p(0, 60));
		line1.runAction(cc.sequence(cc.spawn(move1,scale),move2));
	},
	upLine2:function(){
		var tube1=this.getChildByTag(TAG_TUBE2);
		var line1=tube1.getChildByTag(TAG_LINE_3);
		line1.setVisible(true);
		var move1=cc.moveBy(0.2,cc.p(0, 10));
		var scale=cc.scaleBy(0.2,10);
		var move2=cc.moveBy(0.8,cc.p(0, 60));
		line1.runAction(cc.sequence(cc.spawn(move1,scale),move2));
	},
	upLine1_1:function(){
		var tube1=this.getChildByTag(TAG_TUBE1);
		var line1=tube1.getChildByTag(TAG_LINE_2);
		var move=cc.moveBy(1,cc.p(0, 8));
		line1.runAction(move);
	},
	callback:function(p){
		switch(p.getTag()){
		}
	}
});
